<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>类式组件</title>

    <style>
        header{
            height: 100px;
            background-color: rgb(183, 131, 201);
        }
        main{
            height: 200px;
            background-color: rgb(168, 165, 212);
        }
    </style>
    
</head>
<body>
    <div id="root"></div>

    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>

    <script type="text/babel">
        //1. 声明一个类
        class Header extends React.Component{
            //声明一个方法 render
            render(){
                //返回虚拟 DOM 对象
                return <header>我是顶部区域</header>
            }
        }

        class Main extends React.Component{
            render(){
                return <main>我是内容区</main>
            }
        }

        //2. 将组件渲染到容器中     
        // 内部会对类, 进行实例化, 创建实例化对象, 然后调用 render 方法, 返回虚拟DOM对象, 最终将虚拟DOM渲染到页面中
        ReactDOM.render(<div>
                <Header/>
                <Main />
            </div>, document.querySelector('#root'));

    </script>
</body>
</html>